
package com.ce.cases.collegial.action;


import java.util.Date;
import java.util.List;

import com.ce.cases.collegial.dao.po.CaseSourceCollegial;
import com.ce.cases.source.dao.po.CaseSource;
import com.ce.framework.datamaintain.action.DataMaintainAction;
import com.ce.framework.exception.AppException;
import com.ce.framework.util.BeanAccessUtil;
import com.ce.framework.util.GeneratorUUID;
import com.ce.framework.util.StringUtil;
import com.ce.sys.login.model.User;


/**
* 嫦娥软件有限公司 版权所有 2013
* 创建人：　andy
* 创建日期：2014-04-11
* 创建时间：10:00:00
* 功能描述：市局合议台账 [CASE_SOURCE_COLLEGIAL]更改时用的Action
* ==============================================
* 修改历史
* 修改人		修改时间		修改原因
*
* ==============================================
*/
public class CaseSourceCollegialAction extends DataMaintainAction 
{
	@SuppressWarnings("unchecked")
	public String regEditPage(){
		  String caseId=this.getSelectId();
		  try {
			List<CaseSourceCollegial> exeList = (List<CaseSourceCollegial>) this.baselogic
					.searchByHql("From CaseSourceCollegial po where po.caseId='"+ caseId + "'");
			if(!exeList.isEmpty()){
				po=exeList.get(0);
			}else{
				CaseSource source = (CaseSource) this.baselogic.getPOByPk(
						"com.ce.cases.source.dao.po.CaseSource", caseId);
				BeanAccessUtil.copyProperty(po, "caseId", caseId);
				BeanAccessUtil.copyProperty(po, "caseNumber", source.getCaseNumber());
				BeanAccessUtil.copyProperty(po, "enterprice", source.getInvolvedEnterprice());
				BeanAccessUtil.copyProperty(po, "registerPerson", User.getUserName());
				BeanAccessUtil.copyProperty(po, "regiserDeptId", User.getUserOrgId());
				BeanAccessUtil.copyProperty(po, "regiserDate", new Date());
				BeanAccessUtil.copyProperty(po, "commitDate", new Date());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "openEditPage";
	}
	
    public String regEdit(){
    	try {
			if (StringUtil.isNotBlank(po.getVcId())) {
				this.baselogic.updatePo(po);
			} else {
				po.setVcId(GeneratorUUID.generateUUID());
				this.baselogic.addPo(po);
			}
		} catch (AppException e) {
			e.printStackTrace();
			return this.returnInfoForJS(false, e.getMessage());
		}
		return this.returnInfoForJS(true, "合议记录保存成功！");
	}
    
    

}

